package com.cc.eb.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cc.eb.service.IndexService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @Description: 用一句话描述
 * @Auther: 新梦想*陈超
 * @Date: 2022/1/7 09:52
 */
@Controller//证
@RequestMapping("/index")//工号
public class IndexController {//迎宾
    @Resource
    private IndexService indexService;
    @RequestMapping("/index")
    public String index(Model model,
                        @RequestParam(value = "psize",defaultValue = "1") int psize,
                        @RequestParam(value = "pageSize",defaultValue = "8") int pageSize) {//alt+enter
        System.out.println("接收到一个浏览器的请求......");
        //TODO  1.调用service层首页数据
        Map<String, Page> resultMap = indexService.index(psize, pageSize);
       //2.TODO 2.将数据放到model---数据
        model.addAttribute("resultMap",resultMap);
        //TODO 3.返回view---html
        return  "index";//templates/index.html发送给浏览器
    }
}
